/*****************************************************************************************
 * FILE NAME: drv_upgrade                       COPYRIGHT (c) cos 2024
 * REVISION:  1.0.0                                     All Rights Reserved
 * DESCRIPTION:
 * =======================================================================================
 * UPDATE HISTORY:
 * REV      AUTHOR      DATE
 * v1.0.0   Tuxin       2024.10.14
 * DESCRIPTION OF CHANGE:
 ****************************************************************************************/
#ifndef __DRV_UPGRADE_H
#define __DRV_UPGRADE_H

//----------------------------------------------------------------------------------------
// @Project Includes
#include "typedefs.h"

//----------------------------------------------------------------------------------------
// @Global Macro Define in the module

//----------------------------------------------------------------------------------------
// @Global Type defines in the module
#pragma pack(1)
typedef struct stc_ota_updatainfo
{
    uint32_t u32fwSize; 			/* 需更新固件的文件长度,单位字节*/	
    uint16_t u16fwCrc16; 			/* 需更新固件的crc校验值 */
    uint16_t u16fwVer; 			/* 需更新固件的版本号 */
    uint16_t isFinish;				/* 升级状态*/
    uint8_t timeout;				/* 升级等待时间*/
    uint8_t  ecu;					/*ECU类型 */
    uint32_t offset;				/*升级偏移基地址*/
    uint16_t len;					/* 申请数据长度*/
    int32_t progress; 				/* 升级进度*/
}stc_ota_updatainfo_t;

typedef struct stc_ota_updata
{
    uint16_t flag;					/* 固件升级标志0x5aa5则启动升级 */
    uint8_t  ecu;					/*ECU类型 */
    uint16_t u16fwVer;			/* 需更新固件的版本号 */
    uint32_t u32fwSize;			/* 需更新固件的文件长度,单位字节*/	
    uint16_t u16fwCrc16;			/* 需更新固件的crc校验值 */
}stc_ota_updata_t;
#pragma pack()
#define UPDATE_TAG_SIZE	sizeof(stc_ota_updata_t)/*13*/

//----------------------------------------------------------------------------------------
// @Export global Variables declare in the module
extern stc_ota_updata_t gstcOtaUpdata;			/*存FLASH用*/
extern stc_ota_updatainfo_t gstcOtaUpdataInfo;	/*数据交换用用*/

//----------------------------------------------------------------------------------------
// @Export declaration of functions in the module
bool drv_upgrade_check(void);

#endif

// =======================================================================================
// End of file.
// =======================================================================================
